import React from 'react';
import {Route, Routes, Outlet} from 'react-router-dom';

import {LocalizationProvider} from '@mui/x-date-pickers/LocalizationProvider';
import {AdapterDayjs} from '@mui/x-date-pickers/AdapterDayjs';

import App from './app';
import LoginPage from './pages/login';
import RegisterPage from './pages/register';

import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn'; // 导入中文本地化

dayjs.locale('zh-cn'); // 使用中文本地化

const MyApp = () =>
    <LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale='zh-cn'>
        <App/>
    </LocalizationProvider>;

const AppRoutes = () =>
    <Routes>
        <Route path="/" element={<MyApp/>}/>
        <Route path="/index" element={<MyApp/>}/>

        <Route path="/register" element={<Outlet/>}>
            <Route index element={<RegisterPage/>}/>
            <Route path=":code" element={<RegisterPage/>}/>
        </Route>

        <Route path="/login" element={<LoginPage/>}/>
    </Routes>;

export default AppRoutes;
